<!--
单个文档查询界面
-->
<!DOCTYPE html>
<html>
<head>
    <title>档案管理系统</title>

    <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
    <meta content="width=device-width, initial-scale=1" name="viewport"/>
    <meta name="_csrf" content="2a049f84-561c-44bf-ae25-f24fbf78b313">
    <meta name="_csrf_header" content="X-CSRF-TOKEN">


    <script src="/wedding_admin/js/common.js"></script>
    <script src="/wedding_admin/js/jquery.min.js"></script>
    <script src="/wedding_admin/js/kendo/kendo.all.min.js"></script>
    <script src="/wedding_admin/js/jszip.min.js"></script>
    <script src="/wedding_admin/js/um/respond.min.js"></script>
    <script src="/wedding_admin/js/um/es5-shim.min.js"></script>

    <script src="/wedding_admin/js/kendo/kendo.culture.zh-CN.js"></script>
    <script src="/wedding_admin/js/kendo/kendo.messages.zh-CN.js"></script>
    <script src="/wedding_admin/js/kendo/kendo.hap.js?v=20180330"></script>
    <script src="/wedding_admin/js/um/moment.min.js"></script>
    <script src="/wedding_admin/js/um/daterangepicker.js"></script>
    <script src="/wedding_admin/statics/js/layui/layui.js"></script>

    <script src="/wedding_admin/js/vue_table/vue.min.js"></script>
    <script src="/wedding_admin/js/vue_table/vue-validator.min.js"></script>

    <script src="/wedding_admin/js/treegrid/tree.table.js"></script>
    <script src="/wedding_admin/js/treegrid/jquery.treegrid.extension.js"></script>
    <script src="/wedding_admin/js/treegrid/jquery.treegrid.min.js"></script>
    <script src="/wedding_admin/js/ztree/jquery.ztree.all.min.js"></script>

    <script src="/wedding_admin/js/bootstrap/bootstrap.min.js"></script>


    <link href="/wedding_admin/statics/js/layui/css/layui.css" rel="stylesheet" type="text/css">
    <link href="/wedding_admin/statics/css/font-awesome.min.css" rel="stylesheet" type="text/css">
    <link href="/wedding_admin/statics/css/simple-line-icons.min.css" rel="stylesheet" type="text/css">
    <link href="/wedding_admin/css/ztree/css/metroStyle/metroStyle.css" rel="stylesheet" type="text/css"/>
    <link href="/wedding_admin/css/bootstrap.min.css" rel="stylesheet" type="text/css"/>
    <link href="/wedding_admin/css/font-awesome.min.css" rel="stylesheet" type="text/css"/>
    <link href="/wedding_admin/css/um/kendo.common-bootstrap.min.css" rel="stylesheet" type="text/css"/>
    <link href="/wedding_admin/css/um/kendo.bootstrap.min.css" rel="stylesheet" type="text/css"/>
    <link href="/wedding_admin/css/um/kendo.hap.css" rel="stylesheet" type="text/css"/>
    <link href="/wedding_admin/css/um/daterangepicker.css" rel="stylesheet">
    <link href="/wedding_admin/statics/css/toastr.min.css" rel="stylesheet" type="text/css">
</head>


<body>


<div class="page-container" id="rrapp">
    <div class="col-12 cards-wrap">


        <div class="row center-xs card-items-wrap" style="">


            <div style="margin-left: 8px" class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
                <ul class="layui-tab-title">
                    <li class="layui-this">正文内容</li>
                    <li>文档属性</li>
                    <li>文档共享</li>
                    <li>文档日志</li>
                </ul>
                <div class="layui-tab-content" style="height: 800px;width: 100%">
                    <!--正文内容-->
                    <div class="layui-tab-item layui-show">

                        <iframe id="frameid"
                                width="100%" height="600px;"></iframe>

                    </div>
                    <!--文档属性-->
                    <div class="layui-tab-item">
                        <table class="layui-table">
                            <colgroup>
                                <col width="100">
                                <col width="300">
                                <col width="100">
                                <col width="300">
                            </colgroup>

                            <tbody>
                            <tr>
                                <th>文档编号</th>
                                <td><input class="form-control" readonly="readonly"
                                           style="border-width: 0;width: 100%; height: 100%" v-model="door.doccode">
                                </td>
                                <th>文档目录</th>
                                <td><input class="form-control" readonly="readonly"
                                           style="border-width: 0;width: 100%; height: 100%"
                                           v-model="door.categoryname">
                                </td>
                            </tr>
                            <tr>
                                <th>文档所有者</th>
                                <td><input class="form-control" readonly="readonly"
                                           style="border-width: 0;width: 100%; height: 100%" v-model="door.documentName">
                                </td>
                                <th>文档状态</th>
                                <td><input class="form-control" readonly="readonly"
                                           style="border-width: 0;width: 100%; height: 100%" v-model="door.delFlag">
                                </td>
                            </tr>
                            <tr>
                                <th>创建日期</th>
                                <td><input class="form-control" readonly="readonly"
                                           style="border-width: 0;width: 100%; height: 100%" v-model="door.createDate">
                                </td>
                                <th>最后修改时间</th>
                                <td><input class="form-control" readonly="readonly"
                                           style="border-width: 0;width: 100%; height: 100%"
                                           v-model="door.modifierDate">
                                </td>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                    <!--文档共享-->
                    <div class="layui-tab-item">

                        <div class="form-group">
                            <div class="col-sm-1 control-label">所属用户</div>
                            <div class="col-sm-18">
                                <div id="grid"></div>
                            </div>
                        </div>

                    </div>
                    <!--文档日志-->
                    <div class="layui-tab-item">

                        <div class="form-group">
                            <div class="col-sm-1 control-label">日志信息</div>
                            <div class="col-sm-18">
                                <div id="grid01"></div>
                            </div>
                        </div>

                    </div>

                </div>

            </div>


        </div>
    </div>
    <script>
        layui.use('element', function () {
            var $ = layui.jquery
                , element = layui.element;
            //Hash地址的定位
            var layid = location.hash.replace(/^#test=/, '');


        });
    </script>

</div>

<script>


    var vm = new Vue({
        el: '#rrapp',
        data: {
            showList: true,
            title: null,
            door: {
                categoryname: "",//目录名称
                doccode: "",//文档编号
                documentName: "",//文档所有者
                delFlag: "", //文档状态
                createDate: "",//文档创建日期
                modifierDate: ""//最后修改时间

            },
            menu: {
                parentName: null,
                maincategoryId: 0,
                type: 1,
                orderNum: 0
            }
        },
        mounted() {
            //初始化执行方法
            /**
             *查询信息
             */
            this.getMenu();
        },
        methods: {

            getMenu: function () {

                $.ajax({
                    type: "POST",
                    url: "/wedding_admin/sys/sysdocument/info",
                    contentType: "application/json",
                    data: JSON.stringify({
                        "documentId": this.GetQueryString("documentId"),
                    }),
                    success: function (r) {
                        if (r.code == 0) {

                            //赋值正文链接
                            var reg = /^["|'](.*)["|']$/g;
                            $("#frameid").attr("src", '/' + JSON.stringify(r.Info.sysDocumentEntity.accessoryurl).replace(reg, "$1"));
                            //文档属性
                            vm.door.categoryname = JSON.stringify(r.Info.parentName).replace(reg, "$1")
                            if (r.Info.sysDocumentEntity.doccode!=""&& r.Info.sysDocumentEntity.doccode!=null){
                                vm.door.doccode = JSON.stringify(r.Info.sysDocumentEntity.doccode).replace(reg, "$1")
                            }

                            vm.door.documentName = JSON.stringify(r.Info.documentName).replace(reg, "$1")
                            /**
                             0:草稿，1:正常,2:待发布,3:失效,4:作废
                             */
                            if (JSON.stringify(r.Info.sysDocumentEntity.delFlag) == 0) {
                                vm.door.delFlag = "草稿";
                            } else if (JSON.stringify(r.Info.sysDocumentEntity.delFlag) == 1) {
                                vm.door.delFlag = "正常";
                            } else if (JSON.stringify(r.Info.sysDocumentEntity.delFlag) == 2) {
                                vm.door.delFlag = "待发布";
                            } else if (JSON.stringify(r.Info.sysDocumentEntity.delFlag) == 3) {
                                vm.door.delFlag = "失效";
                            } else if (JSON.stringify(r.Info.sysDocumentEntity.delFlag) == 4) {
                                vm.door.delFlag = "作废";
                            }
                            vm.door.createDate = JSON.stringify(r.Info.sysDocumentEntity.createDate).replace(reg, "$1")
                            if (r.Info.sysDocumentEntity.modifierDate!=""&& r.Info.sysDocumentEntity.modifierDate!=null){
                                vm.door.modifierDate = JSON.stringify(r.Info.sysDocumentEntity.modifierDate).replace(reg, "$1")
                            }

                        } else {
                            alert("数据获取异常")
                        }


                    }
                });

            },
            GetQueryString: function (name) {
                var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
                var r = window.location.search.substr(1).match(reg);
                if (r != null) {
                    return unescape(r[2]);
                }
                return null;
            }


        }
    });

    //回车键触发方法
    document.onkeydown = keyEnter;

    function keyEnter() {
        if (window.event.keyCode == 13) {
            //执行方法
            $("#search").click();

        }
    }

    function GetParam(paraName) {
        var url = document.location.toString();
        var arrObj = url.split("?");
        if (arrObj.length > 1) {
            var arrPara = arrObj[1].split("&");
            var arr;
            for (var i = 0; i < arrPara.length; i++) {
                arr = arrPara[i].split("=");
                if (arr != null && arr[0] == paraName) {
                    return arr[1];
                }
            }
            return "";
        } else {
            return "";
        }
    }
    //-----------------------------
    var crudServiceBaseUrl = "/wedding_admin/sys/sysdocshare/documentGetShareList/" +GetParam("documentId"),
        dataSource = new kendo.data.DataSource({
            transport: {
                read: {
                    url: crudServiceBaseUrl,
                    type: "POST",
                    dataType: "json"
                },
                parameterMap: function (options, type) {

                    if (type !== "read" && options.page) {

                        var datas = Hap.prepareSubmitParameter(options, type);

                        return kendo.stringify(datas);
                    } else if (type === "read") {

                        return {//分页参数
                            limit: options.pageSize,  //当前页码
                            page: options.page  //每页显示记录数

                        }
                    }
                }
            },
            batch: true,
            serverPaging: true,
            pageSize: 10,
            schema: {
                data: function (data) {

                    return data.page.list;


                },
                total: function (data) {

                    if (data.page.totalCount > 0) {
                        return data.page.totalCount;
                    } else {
                        return 0
                    }


                },
                model: {
                    id: "id",
                    fields: {
                        create_time: {type: "date", format: "{0:yyyy-MM-dd HH:mm:ss}"}
                    }
                }
            }


        });


    var grid = $("#grid").kendoGrid({
        dataSource: dataSource,
        dataBound: function () {

            if (parent.autoResizeIframe) {
                parent.autoResizeIframe('HSP_SERVICE_INSTANCE')
            }
        },
        resizable: true,
        scrollable: true,
        navigatable: false,
        editable: false,
        selectable: 'multiple,rowbox',
        pageable: {
            pageSizes: [10, 20, 50, 100, 200, 500],
            refresh: true,
            buttonCount: 5
        },
        columns: [
            {
                field: "id",
                title: '共享ID',
                width: 80,

                headerAttributes: {
                    "class": "table-header-cell",
                    style: "text-align: center"
                },
                attributes: {
                    style: "overflow: hidden; text-overflow: ellipsis; white-space: nowrap;text-align: center"
                }
            },
            {
                field: "name",
                title: '对象名称',
                width: 80,
                headerAttributes: {
                    "class": "table-header-cell",
                    style: "text-align: center"
                },
                attributes: {
                    style: "overflow: hidden; text-overflow: ellipsis; white-space: nowrap;text-align: center"
                }
            },
            {
                field: "sharetype",
                title: '共享类型',
                width: 80,
                headerAttributes: {
                    "class": "table-header-cell",
                    style: "text-align: center"
                },
                attributes: {
                    style: "overflow: hidden; text-overflow: ellipsis; white-space: nowrap;text-align: center"
                },
                template: function (dataItem) {
                    //共享类型(1人力资源，2部门，3角色，4所有人)
                    if (JSON.stringify(dataItem.sharetype) == 1) {
                        return "人力资源"
                    } else if (JSON.stringify(dataItem.sharetype) == 2) {
                        return "部门"
                    } else if (JSON.stringify(dataItem.sharetype) == 3) {
                        return "角色"
                    } else if (JSON.stringify(dataItem.sharetype) == 4) {
                        return "所有人"
                    }
                }
            },
            {
                field: "sharelevel",
                title: '权限',
                width: 80,
                headerAttributes: {
                    "class": "table-header-cell",
                    style: "text-align: center"
                },
                attributes: {
                    style: "overflow: hidden; text-overflow: ellipsis; white-space: nowrap;text-align: center"
                },
                template: function (dataItem) {
                    //共享级别(	1：查看，2：编辑)
                    if (JSON.stringify(dataItem.sharelevel) == 1) {
                        return "查看"
                    } else if (JSON.stringify(dataItem.sharelevel) == 2) {
                        return "编辑"
                    }
                }
            },
            {
                field: "downloadlevel",
                title: '下载权限',
                width: 80,
                headerAttributes: {
                    "class": "table-header-cell",
                    style: "text-align: center"
                },
                attributes: {
                    style: "overflow: hidden; text-overflow: ellipsis; white-space: nowrap;text-align: center"
                },
                template: function (dataItem) {

                    if (JSON.stringify(dataItem.downloadlevel) == 1) {
                        return "可下载"
                    } else {
                        return "不可下载"
                    }
                }

            },


        ]
    }).data("kendoGrid");


    var container = $("#backupWindow");
    kendo.init(container);
    container.kendoValidator({
        invalidMessageType: "tooltip"
    });


    Hap.autoResizeGrid("#grid");

    /*---------------日志信息------------------*/
    var crudServiceBaseUrl01 = "/wedding_admin/sys/sysdocdetaillog/docdetaillogList/" +GetParam("documentId"),
        dataSource01 = new kendo.data.DataSource({
            transport: {
                read: {
                    url: crudServiceBaseUrl01,
                    type: "POST",
                    dataType: "json"
                },
                parameterMap: function (options, type) {

                    if (type !== "read" && options.page) {

                        var datas = Hap.prepareSubmitParameter(options, type);

                        return kendo.stringify(datas);
                    } else if (type === "read") {

                        return {//分页参数
                            limit: options.pageSize,  //当前页码
                            page: options.page  //每页显示记录数

                        }
                    }
                }
            },
            batch: true,
            serverPaging: true,
            pageSize: 10,
            schema: {
                data: function (data) {

                    return data.page.list;


                },
                total: function (data) {

                    if (data.page.totalCount > 0) {
                        return data.page.totalCount;
                    } else {
                        return 0
                    }


                },
                model: {
                    id: "id",
                    fields: {
                        create_time: {type: "date", format: "{0:yyyy-MM-dd HH:mm:ss}"}
                    }
                }
            }


        });


    var grid = $("#grid01").kendoGrid({
        dataSource: dataSource01,
        dataBound: function () {

            if (parent.autoResizeIframe) {
                parent.autoResizeIframe('HSP_SERVICE_INSTANCE')
            }
        },
        resizable: true,
        scrollable: true,
        navigatable: false,
        editable: false,
        selectable: 'multiple,rowbox',
        pageable: {
            pageSizes: [10, 20, 50, 100, 200, 500],
            refresh: true,
            buttonCount: 5
        },
        columns: [
            {
                field: "createDate",
                title: '日期',
                width: 80,

                headerAttributes: {
                    "class": "table-header-cell",
                    style: "text-align: center"
                },
                attributes: {
                    style: "overflow: hidden; text-overflow: ellipsis; white-space: nowrap;text-align: center"
                }
            },
            {
                field: "name",
                title: '操作者',
                width: 80,
                headerAttributes: {
                    "class": "table-header-cell",
                    style: "text-align: center"
                },
                attributes: {
                    style: "overflow: hidden; text-overflow: ellipsis; white-space: nowrap;text-align: center"
                }
            },
            {
                field: "operatetype",
                title: '类型',
                width: 80,
                headerAttributes: {
                    "class": "table-header-cell",
                    style: "text-align: center"
                },
                attributes: {
                    style: "overflow: hidden; text-overflow: ellipsis; white-space: nowrap;text-align: center"
                },
                template: function (dataItem) {
                    //共享类型(1人力资源，2部门，3角色，4所有人)
                    if (JSON.stringify(dataItem.operatetype) == 0) {
                        return "阅读"
                    } else if (JSON.stringify(dataItem.operatetype) == 1) {
                        return "新建"
                    } else if (JSON.stringify(dataItem.operatetype) == 2) {
                        return "修改"
                    } else if (JSON.stringify(dataItem.operatetype) == 4) {
                        return "发布"
                    } else if (JSON.stringify(dataItem.operatetype) == 5) {
                        return "作废"
                    } else if (JSON.stringify(dataItem.operatetype) == 6) {
                        return "下载"
                    }
                }
            },
         {
                field: "ip",
                title: 'IP',
                width: 80,
                headerAttributes: {
                    "class": "table-header-cell",
                    style: "text-align: center"
                },
                attributes: {
                    style: "overflow: hidden; text-overflow: ellipsis; white-space: nowrap;text-align: center"
                }
            }



        ]
    }).data("kendoGrid");


    var container = $("#backupWindow");
    kendo.init(container);
    container.kendoValidator({
        invalidMessageType: "tooltip"
    });


    Hap.autoResizeGrid("#grid01");
</script>

</body>
</html>
